package com.iha.ponggame;
import java.util.Random;

public class Ball {

	static final Random rand = new Random();
	public float x, y;
	public float dirX, dirY;
	private float hitcounter = 0;

	public Ball() {
		x=320/2;
		y=480/2;
		dirX=250;
		dirY=250;
	}
	
	public void update(float deltaTime) {
		x = x + dirX*deltaTime;
		y = y + dirY*deltaTime;

		if (x < 0) {
			hitcounter = hitcounter + 1;
			dirX = -(dirX * 1+hitcounter);
			x = 0;
		}

		if (x > 320) {
			hitcounter = hitcounter + 1;
			dirX = -(dirX * 1+hitcounter);
			x = 320;
		}

		if (y < 0) {
			hitcounter = hitcounter + 1;
			dirY = -(dirY * 1+hitcounter);
			y = 0;
		}

		if (y > 480) {
			hitcounter = hitcounter + 1;
			dirY = -(dirY * 1+hitcounter);
			y=480;
		}
	}
}
